package com.xypower.io;

import javax.sound.midi.Soundbank;
import java.io.*;

public class ioTest {
    //一个文件，包含多少个字母、多少个字符、多少个数字、多少个空格、多少行
    public static void main(String[] args) throws IOException {
        //文件位置
        File files = new File("d:\\demo.txt");
        //文件输入流，节点流
        FileInputStream inputStream = new FileInputStream(files);
        //包装流,转换为字符流
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
        //缓冲流
//        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        byte[] bytes = new byte[(int) files.length()];
        inputStream.read(bytes);
        int lineNum1 = 0;

            for (byte aByte : bytes) {
            if (aByte=='\n'){
                lineNum1++;
            }
        }
        System.out.println(lineNum1+1);

          inputStream.close();
//        String line = null;
//        int lineNum = 0;


//        while ((line = bufferedReader.readLine()) != null){
//            System.out.println(line);
//            lineNum++;
//        }
//        System.out.println(lineNum);
//        System.out.println(bufferedReader.readLine());
//        bufferedReader.close();

    }
}
